import "./index.scss";
import Alert from "./Alert";
import { useState } from "react";
import ReactDOM from "react-dom";

const App = () => {
  //获取根元素
  const root = document.getElementById("root");
  const [visible, setVisible] = useState(false);
  return (
    <div className="box">
      {visible && ReactDOM.createPortal(<Alert setVisible={setVisible}></Alert>,root)}
      <button onClick={() => setVisible(true)}>alert</button>
    </div>
  );
};
export default App;
